<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<script type="text/javascript">
		let obj = {
			name : "联轴器"
			age : 18
		}

		//用for in遍历数组   for in遍历数组得到时候返回的是下标，遍历对象的时候返回的是属性名

		for(var i in obj){
			console.log(i)
		}

		//for of 在遍历对象的时候默认是报错的  obj is not iterable
		// for (var i of obj){
		// 	console.log(i)
		// }

		for (var i of Object.keys(obj)){
			console.log(i)//遍历属性名
		}

		for(var i of Object.values(obj)){
			console.log(i)//遍历属性值
		}

		for(var i of Object.entries(obj)){
			console.log(i)//遍历属性名和属性值  组成一个数组
		}
	</script>
</body>
</html>